<?php
	$max_interval = 60*60*15;
	
	//$fileArr = array("../data/web_arrival.xml","../data/web_depart.xml");
	$fileArr = array("../joomla.xml","../index.php");
	$str = "";
	foreach($fileArr as $file1){
		$flag = false;
		$last_update = date ("m-d-Y H:i:s", filemtime($file1));
		$current_sec = (date("H") * 60 * 60) + (date("i") * 60) + (date("s"));
		$file_sec = (date("H", filemtime($file1)) * 60 * 60) + (date("i", filemtime($file1)) * 60) + (date("s", filemtime($file1)));
		
		$interval = $current_sec - $file_sec;
		
		if(date("Ymd") > date ("Ymd", filemtime($file1))) $flag = true;		
		if($interval >= $max_interval) $flag = true;
		
		if($flag){			
			$file1	 = str_replace("../","",$file1);
			$str .= "<strong>" . $file1 . "</strong> <em>(Last update: ".$last_update.")</em><br />";
			
		}
	}
	
	if($str != ""){
		//$to      = 'qateam2@netneighbours.com';
		$to       = 'phpteam4@citytechcorp.com';
		$subject  = 'Yqr.ca: Error in xml';
		$message  = '<h3>Dear Administrator,</h3>';
		$message .= 'Please update the xml files for run the website properly.<br /> Please see the files details below:<br />'.$str.'<p>Regards,<br />Yqr.ca</p>';
		$headers  = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		$headers .= 'From: info@citytechsoftware.com' . "\r\n" .
			        'Reply-To: sales@citytechsoftware.com' . "\r\n" .
			        'X-Mailer: PHP/' . phpversion();
		
		mail($to, $subject, $message, $headers);
	}
	
?>